package org.dllwh.alibaba.nacos.plugin.datasource.dialect;


import org.dllwh.alibaba.nacos.plugin.datasource.constants.DatabaseTypeConstant;

/**
 * 把今天最好的表现当作明天最新的起点．．～
 * <p>
 * Today the best performance as tomorrow the newest starter!
 *
 * @ClassName SqlServerDatabaseDialect
 * @Description TODO(这里用一句话描述这个类的作用)
 * @Date 2025-10-09 10:30
 * @版本 V 1.0.1
 * @see <a href="">TODO(连接内容简介)</a>
 * @since JDK 17
 */
public class SqlServerDatabaseDialect extends AbstractDatabaseDialect {

    @Override
    public String getType() {
        return DatabaseTypeConstant.SQLSERVER;
    }

    @Override
    public String getLimitTopSqlWithMark(String sql) {
        return sql + " ORDER BY id OFFSET 0 ROWS FETCH NEXT ? ROWS ONLY ";
    }

    @Override
    public String getLimitPageSqlWithMark(String sql) {
        return sql + " ORDER BY id OFFSET ? ROWS FETCH NEXT ? ROWS ONLY ";
    }

    @Override
    public String getLimitPageSql(String sql, int pageNo, int pageSize) {
        return sql + " ORDER BY id OFFSET " + getPagePrevNum(pageNo, pageSize)
                + " ROWS FETCH NEXT " + pageSize + " ROWS ONLY ";
    }

    @Override
    public String getLimitPageSqlWithOffset(String sql, int startOffset, int pageSize) {
        return sql + " ORDER BY id OFFSET " + startOffset + " ROWS FETCH NEXT "
                + pageSize + " ROWS ONLY ";
    }
}
